home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5208 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  43 lines

  1. Path: inforamp.net!ts39-09
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: int main() vs int main(void)
  5. Date: Thu, 08 Feb 96 18:13:57 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4fde76$flj@sam.inforamp.net>
  8. References: <1996Feb7.201848.18734@atlas.tntech.edu>
  9. NNTP-Posting-Host: ts39-09.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <1996Feb7.201848.18734@atlas.tntech.edu>,
  13.    jad7084@tntech.edu (Jim Davis) wrote:
  14. >Okay, void main() is naughty, but there's something else I've been
  15. >wondering about, and I can't find it in the FAQ.
  16. >
  17. >Is there a difference between
  18. >
  19. >  int main()
  20. >  int main(void)
  21. >
  22. >?  () is equivalent to (void), right?  Does it matter?  Am I worried about
  23. >nothing?
  24. >
  25.  
  26. My understanding is that in C++, there is absolutely no difference.  But in C, 
  27. there is a slight difference.  I think the proper example is the following...
  28.  
  29. void f(void);
  30. void f(){};
  31.  
  32. This two line program is the key.  It compile in C++ and doesn't in C.  You 
  33. have to change the program to...
  34.  
  35. void f(void);
  36. void f(void){};
  37.  
  38. ..for it to compile in C.  But, I'm not an expert on the subject.  So, I'd 
  39. confirm this by compiling the programs yourself.  No other differences exist 
  40. in my books.
  41.  
  42. Agrivar
  43.